package cn.yeziji.forum.bo.chatroom;

import cn.yeziji.forum.basic.netty.chat.ChatMessage;
import cn.yeziji.forum.basic.netty.user.UserMessage;
import lombok.Data;

import java.util.Date;

/**
 * 私聊聊天记录BO
 *
 * @author gzkemays
 * @since 2022/12/03 11:18 AM
 */
@Data
public class PrivateChatRecordsBO {
  /** 聊天室名称 */
  String chatroom;
  /** 消息发送者 */
  String from;
  /** 消息接收者 */
  String to;
  /** 接收者的头像 */
  String avatar;
  /** 消息内容 */
  String context;
  /** 发送消息的时间 */
  Date publishTime;

  public ChatMessage buildChatMessage() {
    UserMessage fromUserMessage = new UserMessage();
    fromUserMessage.setNickname(this.from);
    fromUserMessage.setAvatar(this.avatar);
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setName(this.chatroom);
    chatMessage.setText(this.context);
    chatMessage.setFrom(fromUserMessage);
    chatMessage.setTo(this.to);
    chatMessage.setPublishTime(this.publishTime);
    return chatMessage;
  }
}
